#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

ll l, r, n;

ll f(ll x) {
    ll cnt = 0, num = 0;
    for (int i = 63; i >= 0; i--) {
        if (n & (1ll << i)) {
            ll low = 1ll << i, high = low + (1ll << i) - 1;
            if (low > x) continue;

            if (x > high) cnt += 1ll << i;
            else cnt += x - low + 1;
        }
    }

    return cnt;
}
int main() {
    cin >> n >> l >> r;

    cout << f(r) - f(l - 1) << endl;
    return 0;
}